﻿using T163.Open.Api.WP7.Model;

namespace T163.Open.Api.WP7.Sample.Utility
{
    public class OAuthClientHelper
    {
        public static bool IsAuthorized()
        {
            if (App.Consumer == null || App.AccessToken == null)
            {
                if (IsoStoreHelper.IsExist(App.CONSUMERTOKEN) && IsoStoreHelper.IsExist(App.ACCESSTOKEN))
                {
                    App.Consumer = IsoStoreHelper.Get<Consumer>(App.CONSUMERTOKEN);
                    App.AccessToken = IsoStoreHelper.Get<AccessToken>(App.ACCESSTOKEN);

                    if (!string.IsNullOrWhiteSpace(App.AccessToken.Token) && !string.IsNullOrWhiteSpace(App.AccessToken.TokenSecret))
                        return true;
                    else
                        return false;
                }
                else
                    return false;
            }

            return true;
        }
    }
}
